﻿@model SDCloudSolution.SDCloud.Web.Models.Model.ModelViewModel

@{
    Layout = MVC.Shared.Views._AuthorizedLayout;
    ViewBag.Title = Model.Name;
}

@section scripts {
    <script src="~/Scripts/js/libs/require/require.js"></script>
    <script src="~/Scripts/app.js"></script>
    <script src="~/Scripts/sdCloud/model.view.js"></script>
}

<h1 class="page-header">
    <a href="@Url.Action(MVC.ModelsGallery.List())">
        <img border="0" src="~/Content/left arrow.png" width="24" height="24">
    </a>
    @Model.Name
</h1>

<div id="model-buttons-container">
    <div>
        <a href="@Url.Action(MVC.Models.Download(Model.ModelId))"
           data-bind="ojComponent: {
                                          component: 'ojButton',
                                          icons: {start:'fa fa-download'}
                                      }">
            Download
        </a>

        <form method="POST" action="@Url.Action(MVC.ModelsGallery.CopyModelToPrivateCollection(Model.ModelId))" style="display: inline-block;">
            <button type="submit" data-bind="ojComponent: {
                                        component: 'ojButton',
                                        icons: { start: 'fa fa-copy'}
                                }">
                Copy
            </button>
        </form>
    </div>
</div>

@if (Model.ModelStatistics != null)
{
    <h3>Model statistics</h3>
    <div class="oj-flex oj-flex-items-pad oj-panel">
        <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
            <div class="oj-header-border bold">Model success run count</div>
            <div>
                @Model.ModelStatistics.TotalSuccessExecutionCount (@Model.ModelStatistics.TotalSuccessExecutionPercentage.ToString("P1"))
            </div>
        </div>
        <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
            <div class="oj-header-border bold">Model failed run count</div>
            <div>
                @Model.ModelStatistics.TotalFailedExecutionCount (@Model.ModelStatistics.TotalFailedExecutionPercentage.ToString("P1"))
            </div>
        </div>
        <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
            <div class="oj-header-border bold">Model total run count</div>
            <div>@Model.ModelStatistics.TotalExecutionCount</div>
        </div>
        <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
            <div class="oj-header-border bold">Average execution time</div>
            <div>@Model.ModelStatistics.AverageExecutionTimeText</div>
        </div>
        <div class="oj-flex-item oj-margin oj-sm-12 oj-lg-3 oj-md-4 oj-xl-2">
            <div class="oj-header-border bold">Average data usage</div>
            <div>@Model.ModelStatistics.AverageDataSizeUsageText</div>
        </div>
    </div>
}

<h3>Model description</h3>
<div class="oj-flex oj-flex-items-pad oj-panel">
    @Model.FormattedDescription
</div>

<h3>File</h3>
<div class="oj-flex oj-flex-items-pad oj-panel">
    <b>@Html.ActionLink(@Model.FileName, MVC.Models.Download(Model.ModelId))</b>
</div>